package site.wetsion.galio.sdk.common;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Set;

/**
 * rms配置类，包含客户端系统的id，密钥配置，以及资源redis的配置
 *
 * @author weixin
 * @version 1.0
 * @CLassName GalioClientDetailsProperties
 * @date 2019/3/8 3:04 PM
 */
@ConfigurationProperties("galio.oauth.client")
public class GalioClientDetailsProperties {

    /** 需要认证的平台ID **/
    private String clientId;

    /** 需要认证的平台密钥 **/
    private String clientSecret;

    /** 需要认证的用户 **/
    private String username;

    /** 需要认证的用户的密码 **/
    private String password;

    private String[] safetyUrl = {"/login"};

    /** 客户端系统配置的重定向URL **/
    private String redirectUrl;

    /** 认证类型：password, 此处仅支持password，建议不配置 **/
    private String grantType = "password";

    /** 获取认证的URL **/
    private String accessTokenUrl;

    /** 校验token的URL **/
    private String checkTokenUrl;

    private String authorizeUrl;

    private String userCheckUrl = "https://rms-auth.k8s.uc.host.dxy/rms/user/check";

    private String userDetailsUrl = "https://rms-auth.k8s.uc.host.dxy/rms/user/details";

    private Redis redis;

    public String getRedirectUrl() {
        return redirectUrl;
    }

    public void setRedirectUrl(String redirectUrl) {
        this.redirectUrl = redirectUrl;
    }

    public String getAuthorizeUrl() {
        return authorizeUrl;
    }

    public void setAuthorizeUrl(String authorizeUrl) {
        this.authorizeUrl = authorizeUrl;
    }

    public String[] getSafetyUrl() {
        return safetyUrl;
    }

    public void setSafetyUrl(String[] safetyUrl) {
        this.safetyUrl = safetyUrl;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public String getClientSecret() {
        return clientSecret;
    }

    public void setClientSecret(String clientSecret) {
        this.clientSecret = clientSecret;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getGrantType() {
        return grantType;
    }

    public void setGrantType(String grantType) {
        this.grantType = grantType;
    }

    public String getAccessTokenUrl() {
        return accessTokenUrl;
    }

    public void setAccessTokenUrl(String accessTokenUrl) {
        this.accessTokenUrl = accessTokenUrl;
    }

    public String getCheckTokenUrl() {
        return checkTokenUrl;
    }

    public void setCheckTokenUrl(String checkTokenUrl) {
        this.checkTokenUrl = checkTokenUrl;
    }

    public String getUserCheckUrl() {
        return userCheckUrl;
    }

    public void setUserCheckUrl(String userCheckUrl) {
        this.userCheckUrl = userCheckUrl;
    }

    public String getUserDetailsUrl() {
        return userDetailsUrl;
    }

    public void setUserDetailsUrl(String userDetailsUrl) {
        this.userDetailsUrl = userDetailsUrl;
    }

    public Redis getRedis() {
        return redis;
    }

    public void setRedis(Redis redis) {
        this.redis = redis;
    }

    public static class Redis {

        private int database = 0;

        /**
         * Redis url, which will overrule host, port and password if set.
         */
        private String url;

        /**
         * Redis server host.
         */
        private String host = "localhost";

        /**
         * Login password of the redis server.
         */
        private String password;

        /**
         * Redis server port.
         */
        private int port = 6379;

        /**
         * Enable SSL.
         */
        private boolean ssl;

        /**
         * Connection timeout in milliseconds.
         */
        private int timeout;

        private String sentinelMaster;

        private Set<String> sentinelNodes;

        public Set<String> getSentinelNodes() {
            return sentinelNodes;
        }

        public void setSentinelNodes(Set<String> sentinelNodes) {
            this.sentinelNodes = sentinelNodes;
        }

        public void setSentinelMaster(String sentinelMaster) {
            this.sentinelMaster = sentinelMaster;
        }

        public String getSentinelMaster() {
            return sentinelMaster;
        }

        public int getDatabase() {
            return database;
        }

        public void setDatabase(int database) {
            this.database = database;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getHost() {
            return host;
        }

        public void setHost(String host) {
            this.host = host;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public int getPort() {
            return port;
        }

        public void setPort(int port) {
            this.port = port;
        }

        public boolean isSsl() {
            return ssl;
        }

        public void setSsl(boolean ssl) {
            this.ssl = ssl;
        }

        public int getTimeout() {
            return timeout;
        }

        public void setTimeout(int timeout) {
            this.timeout = timeout;
        }
    }
}
